package com.aspose.cells;

import java.util.ArrayList;

class zbmc extends zbz {
   private long a = 0L;
   private int d = 0;
   private long e;
   private ArrayList f;
   private int g;
   private zayy[] h;
   private com.aspose.cells.b.a.g.a.ze i;
   private zalh j;
   private zarn k;

   zbmc() {
      this.c(252);
      this.b(8);
      this.f = new ArrayList();
      this.i = new com.aspose.cells.b.a.g.a.ze("[^\\x00-\\x7f]+");
   }

   void a(zbpx var1) {
      this.d = var1.d();
      this.a = var1.c();
      this.h = var1.a;
      this.e = (long)Math.max(this.d / 128 + 1, 8);
   }

   void a(zbpx var1, zalh var2) {
      this.d = var2.d + var2.g.size();
      this.a = var2.i;
      this.h = var1.a;
      this.e = (long)Math.max(this.d / 128 + 1, 8);
      this.j = var2;
   }

   void b(zqa var1) throws Exception {
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.g - 4), 0, this.c, 2, 2);
      var1.a(this.c, this.g);
   }

   void a(zqa var1) throws Exception {
      this.c = new byte[8228];
      this.c[0] = -4;
      this.g = 4;
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.a), 0, this.c, this.g, 4);
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.d), 0, this.c, this.g + 4, 4);
      this.g += 8;
      int var2 = this.j == null ? this.d : this.j.d;

      boolean var5;
      for(int var3 = 0; var3 < var2; ++var3) {
         zayy var4 = this.h[var3];
         var5 = (long)var3 % (this.e & 4294967295L) == 0L;
         this.a(var4, var5, var1);
         if (var5) {
            com.aspose.cells.b.a.a.ze.a(this.f, (Object)this.k);
         }
      }

      if (this.j != null) {
         zayy var6 = new zayy();
         var2 = this.j.g.size();

         for(int var8 = 0; var8 < var2; ++var8) {
            var5 = (long)(var8 + this.j.d) % (this.e & 4294967295L) == 0L;
            var6.c = (String)this.j.g.get(var8);
            this.a(var6, var5, var1);
            if (var5) {
               com.aspose.cells.b.a.a.ze.a(this.f, (Object)this.k);
            }
         }
      }

      this.b(var1);
      this.c = null;
      this.h = null;
      zry var7 = new zry();
      var7.a(var1, this.f);
      this.f.clear();
      this.f = null;
      this.g = this.d = 0;
      this.a = 0L;
   }

   void a(zayy var1, boolean var2, zqa var3) throws Exception {
      int var4 = 3;
      byte[] var5 = null;
      byte[] var6 = null;
      boolean var8 = true;
      byte var9 = 0;
      int var10 = 1;
      byte[] var7;
      if (var1 == null) {
         var7 = new byte[]{114};
      } else {
         String var11 = var1.c;
         if (var11.length() > 32767) {
            var11 = var11.substring(0, 32767);
         }

         var10 = var11.length();
         if (var1.g()) {
            zatv var12 = (zatv)var1;
            var5 = var12.d();
            if (var5 != null) {
               var4 += 4;
               var9 = (byte)(var9 | 4);
            }

            if (var1.f()) {
               var9 = (byte)(var9 | 8);
               var4 += 2;
               var6 = var12.f;
            }
         } else if (var1.f()) {
            var9 = (byte)(var9 | 8);
            var4 += 2;
            var6 = ((zbap)var1).f;
         }

         com.aspose.cells.b.a.g.a.zc var14 = this.i.a(var11);
         if (var14.c()) {
            var7 = Encoding.getUnicode().a(var11);
            var8 = false;
            var9 = (byte)(var9 | 1);
         } else {
            var7 = Encoding.getASCII().a(var11);
         }
      }

      if (this.g + var4 >= this.c.length) {
         this.b(var3);
         this.c[0] = 60;
         this.g = 4;
      }

      if (var2) {
         this.k = new zarn();
         this.k.a = var3.b() + (long)this.g;
         this.k.b = this.g;
      }

      System.arraycopy(com.aspose.cells.b.a.zc.a(var10), 0, this.c, this.g, 2);
      this.g += 2;
      this.c[this.g++] = var9;
      if (var6 != null) {
         System.arraycopy(com.aspose.cells.b.a.zc.a(var6.length / 4), 0, this.c, this.g, 2);
         this.g += 2;
      }

      if (var5 != null) {
         System.arraycopy(com.aspose.cells.b.a.zc.a(var5.length), 0, this.c, this.g, 4);
         this.g += 4;
      }

      int var13;
      int var15;
      if (var7.length + this.g > this.c.length) {
         if (var8) {
            var13 = this.c.length - this.g;
            System.arraycopy(var7, 0, this.c, this.g, var13);
            this.g += var13;
            this.b(var3);
            this.c[0] = 60;
            this.g = 4;
            var15 = var13;
            var13 = var7.length - var13;

            while(var13 + 1 > 8224) {
               this.c[4] = 0;
               System.arraycopy(var7, var15, this.c, 5, 8223);
               var13 -= 8223;
               var15 += 8223;
               this.g = 8228;
               this.b(var3);
            }

            this.c[4] = 0;
            System.arraycopy(var7, var15, this.c, 5, var13);
            this.g = 5 + var13;
         } else {
            var13 = this.c.length - this.g;
            if (var13 % 2 == 1) {
               --var13;
            }

            System.arraycopy(var7, 0, this.c, this.g, var13);
            this.g += var13;
            this.b(var3);
            this.c[0] = 60;
            this.g = 4;
            var15 = var13;
            var13 = var7.length - var13;

            while(var13 + 2 > 8224) {
               this.c[4] = 1;
               System.arraycopy(var7, var15, this.c, 5, 8222);
               var13 -= 8222;
               var15 += 8222;
               this.g = 8227;
               this.b(var3);
            }

            this.c[4] = 1;
            System.arraycopy(var7, var15, this.c, 5, var13);
            this.g = 5 + var13;
         }
      } else {
         System.arraycopy(var7, 0, this.c, this.g, var7.length);
         this.g += var7.length;
      }

      if (var6 != null) {
         if (var6.length + this.g > this.c.length) {
            var13 = (this.c.length - this.g) / 4 * 4;
            if (var13 != 0) {
               System.arraycopy(var6, 0, this.c, this.g, var13);
               this.g += var13;
               this.b(var3);
               this.c[0] = 60;
               System.arraycopy(var6, var13, this.c, 4, var6.length - var13);
               this.g = var6.length - var13 + 4;
            } else {
               this.b(var3);
               this.c[0] = 60;
               System.arraycopy(var6, 0, this.c, 4, var6.length);
               this.g = var6.length + 4;
            }
         } else {
            System.arraycopy(var6, 0, this.c, this.g, var6.length);
            this.g += var6.length;
         }
      }

      if (var5 != null) {
         if (var5.length + this.g > this.c.length) {
            var13 = this.c.length - this.g;
            System.arraycopy(var5, 0, this.c, this.g, var13);
            this.g += var13;
            this.b(var3);
            this.c[0] = 60;
            this.g = 4;
            var15 = var13;
            var13 = var5.length - var13;

            while(var13 > 8224) {
               System.arraycopy(var5, var15, this.c, 4, 8224);
               var13 -= 8224;
               var15 += 8224;
               this.g = 8228;
               this.b(var3);
            }

            System.arraycopy(var5, var15, this.c, 4, var13);
            this.g = 4 + var13;
         } else {
            System.arraycopy(var5, 0, this.c, this.g, var5.length);
            this.g += var5.length;
         }
      }

   }
}
